ARG CENTOS_VERSION
FROM centos:${CENTOS_VERSION}
LABEL maintainer="ikam <xq@uera.cn>"

RUN groupadd -f www && useradd -g www www

# install pkg
RUN yum install -y wget \
    && yum install -y ca-certificates sudo \
    && yum install -y gd \
    && yum install -y git \
    && yum install zsh -y \
    && chsh -s /bin/zsh \
    && REMOTE=https://gitee.com/mirrors/oh-my-zsh.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

ARG BT_INSTALL_PATH
# install bt
RUN set -eux \
    && wget -O install.sh ${BT_INSTALL_PATH} \
    && echo y | sh install.sh


COPY app.sh /

ARG BT_USERNAME
ARG BT_PASSWORD
ARG DNS1
ARG DNS2

ENV BT_USERNAME $BT_USERNAME
ENV BT_PASSWORD $BT_PASSWORD
ENV DNS1 $DNS1
ENV DNS2 $DNS2

RUN chmod +x /app.sh  && sed -i "s/\r//" /app.sh \
	&& sed -i "s|BTUSERNAME=baota|BTUSERNAME=$BT_USERNAME|" /app.sh \
	&& sed -i "s|BTPASSWORD=123456|BTPASSWORD=$BT_PASSWORD|" /app.sh \
	&& sed -i "s|DNS1=8.8.8.8|DNS1=$DNS1|" /app.sh \
	&& sed -i "s|DNS2=8.8.4.4|DNS2=$DNS2|" /app.sh

CMD [ "/app.sh" ]

